<!--
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<section class="identity-issued">
  <header class="modal-header">
    <h1>Identity Issued</h1>
    <button class="icon modal-exit" (click)="activeModal.dismiss()">
      <svg class="ibm-icon" aria-hidden="true">
       <use xlink:href="#icon-close_new"></use>
      </svg>
    </button>
  </header>
  <div class="modal-body">
    <identity-card [identity]="newCard" [preview]="true"></identity-card>

    <div class="new-card-options">
      <ngb-accordion [closeOthers]="true" activeIds="option-1">
          <ngb-panel id="option-1">
            <ng-template ngbPanelTitle>
              <svg class="bx--accordion__arrow" width="12" height="12" viewBox="0 0 8 12" fill-rule="evenodd">
                <path d="M0 10.6L4.7 6 0 1.4 1.4 0l6.1 6-6.1 6z"></path>
              </svg>
              <span>Use it yourself</span>
            </ng-template>
            <ng-template ngbPanelContent>
                <p>Just add the business network card to your wallet to start using the new identity yourself</p>
                <label for="cardName"><h3>Give the business network card a name</h3></label>
                <input type="text" [ngModel]="cardName" id="cardName" name="cardName"
                       (ngModelChange)="setCardName($event)"
                       autocomplete="off" placeholder="e.g. {{newCard.getUserName() + '@' + newCard.getBusinessNetworkName()}}">
                <div *ngIf="!cardNameValid" class="error-message">The card name must be unique</div>
                <div class="actions">
                  <button type="button" class="primary" (click)="addToWallet()" [disabled]="!cardNameValid">Add to wallet</button>
                </div>
            </ng-template>
          </ngb-panel>
          <ngb-panel id="option-2">
              <ng-template ngbPanelTitle>
                  <svg class="bx--accordion__arrow" width="12" height="12" viewBox="0 0 8 12" fill-rule="evenodd">
                    <path d="M0 10.6L4.7 6 0 1.4 1.4 0l6.1 6-6.1 6z"></path>
                  </svg>
                  <span>Send it to someone else</span>
                </ng-template>
            <ng-template ngbPanelContent>
                <p>Another Playground user can import the business network card to their wallet to start using the new identity</p>
                <div class="actions">
                  <button type="button" class="primary" (click)="export();">Export Business Network Card</button>
                </div>
            </ng-template>
          </ngb-panel>
        </ngb-accordion>
    </div>
  </div>
  <footer>
    <p class="footer-text">
      <svg class="standard-icon" aria-hidden="true">
        <use xlink:href="#icon-warn_32"></use>
      </svg>
      For security, new identities can only be enrolled once
    </p>
  </footer>
</section>
